/*
 * RemoveTransitionCommand.java
 *
 * Created on 26 maj 2007, 21:40
 */

package edu.uj.petri.commands;

import edu.uj.petri.document.Document;
import edu.uj.petri.view.TransitionView;
import edu.uj.petri.view.View;
import java.util.ResourceBundle;

/**
 *
 * @author Paweł
 */
public class RemoveTransitionCommand extends Command {
    
    private TransitionView transitionView;
    private Memento memento;
        
    public RemoveTransitionCommand( TransitionView transitionView) {
        
        this.transitionView = transitionView;
    }

    public String toString() {
        
        return String.format(ResourceBundle.getBundle("edu/uj/petri/messages").getString(
                "removing_transition_%s"), transitionView.getNode().toString());
    }

    void execute() {
        
        memento = transitionView.getMemento();
        transitionView.removeFrom( Document.getActiveDocument().getView() );
    }

    void undo() {
        
        transitionView.applyMemento(memento);
        View view = Document.getActiveDocument().getView();
        view.addElement(transitionView);
        view.draw();
        
    }

    boolean canBeCombined(Command c) {
        
        return false;
    }

    private static final long serialVersionUID = 2576716145121659470L;
    
}
